package com.ruidan.server;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class WebServer {
	public void startServer(int port) {
		try {
			ServerSocket server = new ServerSocket(port);
			while (true) {
				Socket socket = server.accept();
				new Processor(socket).start();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		int port = 8888;
		if (args.length == 1) {
			port = Integer.parseInt(args[0]);
		}
		new WebServer().startServer(port);
	}
}
